(function($) {

    //Define global storage
    window.vfqStorage = Array();

    $.fn.delayKeyup = function(callback, ms){
        var timer = 0;
        var el = $(this);
        $(this).bind('keyup blur',function(){

            //Detect changes
            var lastvalue = $(this).attr('lastvalue');
            if (lastvalue === undefined || lastvalue.length == 0) {
                $(this).attr('lastvalue',$(this).val());
            }else{
                if (lastvalue != $(this).val()) {
                    $(this).attr('lastvalue',$(this).val())
                }else{
                    return;
                }
            }

            clearTimeout (timer);
            timer = setTimeout(function(e){
                callback(el);
            }, ms);
        });
        return $(this);
    };

    $.fn.attachValuesFromQuery = function() {

        //Decorations
        function pauseElement(element) {

            if( $(element).next().hasClass('ms-container') ) {
                element = $(element).next();
            }

            if($(element).find('.shadow').length) return;

            var shadow = $('<div/>');
            $(element).css('position','relative');
            $(element).css('display','block');
            $(shadow).css('position','absolute');
            $(shadow).css('left','0');
            $(shadow).css('top','0');
            $(shadow).css('width', $(element).width()+'px' );
            $(shadow).css('height', $(element).height()+'px' );
            $(shadow).css('z-index', 1000 );
            $(shadow).css('background-color', 'black' );
            $(shadow).css('opacity', '0.35' );
            $(shadow).attr('class', 'shadow' );

            var img = $('<div><img/></div>');
            $(img).find('img')[0].src = loading;
            $(img).css('width', '50px');
            $(img).css('height', '50px');
            $(img).css('margin', (($(element).height()/2))+'px auto 0px auto');
            $(img).appendTo(shadow);

            $(shadow).appendTo(element);

            $(element).attr('disabled',true);

        }

        //Decorations
        function unpauseElement(element) {
            if( $(element).next().hasClass('ms-container') ) {
                element = $(element).next();
            }
            $(element).find('.shadow').remove();
            $(element).attr('disabled',false);
        }

        //Prepare query. send it. call callback.
        function doQuery( query, callback ) {

            //console.log(query);

            var request = mw.config.get('wgScriptPath') + "/api.php";
            request += "?action=sfqueryapi&format=json&query=" + query;

            $.get(request, function( data ){

                var result = [];
                if( data.error === undefined ) {
                    result = data.sfqueryapi;
                }else{
                    result = data;
                }

                callback( result );
            });

        }

        function escapeValue( v ) {
            v = v.split('"').join('&quot;');
            v = v.split("'").join('&#39;');
            v = v.replace(/"/gi,'&quot;');
            return v;
        }

        function dataToElement( data, element ) {

            //By default there is only select supported
            var tag = $(element).prop('tagName').toLowerCase();

            switch( tag ) {
                case "select":

                    $(element).find('option').remove();
                    $(data).each(function(i,v){
                        var option = $('<option/>');
                        v.title = escapeValue(v.title);
                        $(option).val(v.title);
                        $(option).html(v.title);
                        $(option).appendTo(element);
                    });

                    break;

                //TODO: code duplication
                case "input":

                    //Detect input type, by default it is autocomplete only supported
                    if( $(element).hasClass('autocompleteInput') ) {
                        var aValues = [];
                        $(data).each(function(i,v){
                            v.title = escapeValue(v.title);
                            aValues.push(v.title);
                        });
                        $(element).autocomplete({
                            source: aValues
                        });
                    }

                    break;

                //TODO: code duplication
                case "textarea":

                    //Detect input type, by default it is autocomplete only supported
                    if( $(element).hasClass('autocompleteInput') ) {
                        var aValues = [];
                        $(data).each(function(i,v){
                            v.title = escapeValue(v.title);
                            aValues.push(v.title);
                        });
                        $(element).autocomplete({
                            source: aValues
                        });
                    }

                    break;

                //Checkboxes & radiobuttons input workaround
                case "span":

                    if( $(element).hasClass('checkboxesSpan') ) {

                        var inputName = $(element).attr('inputname');

                        $(element).find('div').remove();
                        $(element).find('label').remove();

                        $(data).each(function(i,v){

                            var div = $('<div></div>');

                            var checkbox = $('<input type="checkbox"/>');
                            $(checkbox).attr('name',inputName+'['+i+']');
                            v.title = escapeValue(v.title);
                            $(checkbox).val(v.title);
                            $(checkbox).attr('id',inputName+'_'+i);

                            var label = $('<label class="checkboxLabel" />');
                            $(label).attr('for',inputName+'_'+i);
                            $(label).html(v.title);

                            $(checkbox).appendTo(div);
                            $(label).appendTo(div);

                            $(div).appendTo(element);

                        });

                    }

                    //Radiobuttons
                    if( $(element).hasClass('radioButtonSpan') ) {

                        var inputName = $(element).attr('inputname');

                        $(element).find('div').remove();
                        $(element).find('label').remove();

                        $(data).each(function(i,v){

                            var div = $('<div></div>');

                            var radio = $('<input type="radio"/>');
                            $(radio).attr('name',inputName);
                            v.title = escapeValue(v.title);
                            $(radio).val(v.title);
                            $(radio).attr('id',inputName+'_'+i);

                            var label = $('<label class="checkboxLabel" />');
                            $(label).attr('for',inputName+'_'+i);
                            $(label).html(v.title);

                            $(radio).appendTo(div);
                            $(label).appendTo(div);

                            $(div).appendTo(element);

                        });

                    }

                    break;

                default:
                    //We cant handle element with tag
                    break;
            }

            //Test
            unpackElementValues( element );

            if( $(element).next().hasClass('ms-container') && tag == 'select' ) {
                //This select is two-listboxed
                $(element).multiSelect('refresh');
                $(element).next().find('.2listsearchbox').quicksearch('#'+$(element).next().attr('id')+' .ms-selectable li');
            }

        }

        function onSubFieldChange( element ) {

            if( $(element).attr('vfqtid') == undefined ) return;

            //Target
            var eTargets = $(element).attr('vfqtid').split(',');

            $(eTargets).each(function(i,v){

                var eTarget = $('#'+v);

                var sQuery = getQueryString( $(eTarget) );
                var aSub = getQuerySubs( $(eTarget) );

                //Prepare query & check for empty subs
                //TODO: code duplicate
                var query = prepareQuery( sQuery, aSub );
                if( query === false ) {
                    return;
                }

                pauseElement(eTarget);

                doQuery( query , function( data ) {
                    if (data.error !== undefined ) {
                        return;
                    }
                    dataToElement( data, eTarget );
                    unpauseElement(eTarget);
                });

            });

        }

        //Prepare query for send, replacing values
        function prepareQuery( query, subs ) {
            var emptySubs = false;
            //console.log('going threw subs');
            //console.log(subs);
            $(subs).each( function(i,v) {

                if ( !$('[name="'+v+'"]').length ) return true;

                var value = $('[name="'+v+'"]').val();

                if( value.length == 0 ) {

                    if ( $('[name="'+v+'"]').attr('vfqdef') != undefined ) {
                        value = $('[name="'+v+'"]').attr('vfqdef');
                    }

                    if( value.length == 0 ) {
                        emptySubs = true;
                    }
                }
                query = query.replace('#'+(i+1), value );
            });
            if( emptySubs ) {
                return false;
            }else{
                return query;
            }
        }

        //Get query string from attribute "vfq"
        //return String
        function getQueryString( element ) {
            var sQuery = $(element).attr('vfq');
            if ( sQuery === undefined ) {
                return false;
            }
            return sQuery;
        }

        //Get query substitution string from attribute "vfqs" (if there some)
        //return Array
        function getQuerySubs( element ) {
            var sSub = $(element).attr('vfqs');
            var aSub = [];
            if( sSub !== undefined ) {
                //Parse string to array
                if( sSub.indexOf(',') === -1 ) {
                    //There is only single substitute
                    aSub.push( sSub );
                }else{
                    aSub = sSub.split(',');
                }
            }else{
                return false;
            }
            return aSub;
        }

        function unpackElementValues( element ) {

            var hashcode = calculateSubsHash(element);

            console.log('Unpacking element, look hash '+hashcode);

            if (window.vfqStorage[ $(element).attr('id') ][ hashcode ] != undefined) {

                var tag = $(element).prop('tagName').toLowerCase();

                var values = window.vfqStorage[ $(element).attr('id') ][ hashcode ];

                switch( tag ) {
                    case "select":

                        $($(element).find('option')).each(function(i,v){

                            $(values).each(function(k,z){

                                if ( z == $(v).val() ) {
                                    $(v).attr('selected','selected');
                                    console.log('option set selected');
                                }

                            });

                        });

                        break;

                    case "span":

                        if( $(element).hasClass('checkboxesSpan') ) {

                            $($(element).find('input[type="checkbox"]')).each(function(i,v){

                                $(values).each(function(k,z){

                                    if ( z == $(v).val() ) {
                                        $(v).attr('checked','checked');
                                        console.log('checked set checked');
                                    }

                                });

                            });

                        }

                        if( $(element).hasClass('radioButtonSpan') ) {

                            $(element).find('input[type="radio"]').each(function(i,v){

                                if( $(v).val() == values[0] ) {
                                    $(v).attr('checked','checked');
                                    console.log('radio set checked');
                                }

                            });

                        }

                        break;

                    default:

                        $(element).val( values.join(';') );

                        break;
                }

            }

        }

        function packElementValues( element ) {

            var values = getElementValuesArray( element );
            console.log('values:');
            console.log(values);
            //Hashcode
            var hashcode = calculateSubsHash($(element));
            console.log('adding hash '+hashcode);
            window.vfqStorage[$(element).attr('id')][hashcode] = values;
        }

        function getElementValuesArray( element ) {

            //Get tag
            var tag = $(element).prop('tagName').toLowerCase();
            //Get values
            var values = Array();

            switch( tag ) {
                case "select":
                    $( $(element).find('option:selected') ).each(function(i,v){
                        values.push( $(v).val() );
                    });
                    break;

                case "span":

                    if( $(element).hasClass('checkboxesSpan') ) {
                        $( $(element).find('input[type="checkbox"]:checked') ).each(function(i,v){
                            values.push( $(v).val() );
                        });
                    }

                    if( $(element).hasClass('radioButtonSpan') ) {
                        $( $(element).find('input[type="radio"]:checked') ).each(function(i,v){
                            values.push( $(v).val() );
                        });
                    }

                    break;

                default:
                    values.push( $(element).val() );
                    break;
            }

            return values;
        }

        function calculateSubsHash( element ) {

            var hashcode = '';
            // Get subs
            var aSubs = getQuerySubs( $(element) );
            $(aSubs).each(function(i,v){
                var subE = $('[name="'+v+'"]');
                hashcode = hashcode + $(subE).attr('id') + $(subE).val();
            });
            // Calculate
            console.log('Calculated string: '+hashcode);
            hashcode = $.md5(hashcode);
            return hashcode;
        }

        return this.each( function(){

            var sId = $(this).attr('id');
            var eTarget = $(this);

            var sQuery = getQueryString($(this));
            var aSub = getQuerySubs($(this));

            //Add listener to all substitute fields if there is some
            $(aSub).each( function(index, value) {

                //Default value

                //console.log('search:'+value.search(/\((.+)\)/i));
                //console.log('match:'+value.match(/\((.+)\)/i));

                if ( value.search(/\((.+)\)/i) !== -1 ) {
                    var match = value.match(/\((.+)\)/i);
                    var def = match[1];
                    var oldvalue = value;
                    value = value.replace(/\((.+)\)/i, '');
                    $('[name="'+value+'"]').attr('vfqdef',def);

                    var attrSubs = $(eTarget).attr('vfqs');
                    attrSubs = attrSubs.replace(oldvalue,value);
                    $(eTarget).attr('vfqs', attrSubs);

                    //console.log('name '+value+' set def='+def);
                }

                var element = $('[name="'+value+'"]');

                if (element == undefined) {
                    throw "There is no such property as "+value;
                    return true;
                }

                var eTargets = [];
                if( $(element).attr('vfqtid') != undefined ) {
                    eTargets = $(element).attr('vfqtid').split(',');
                }
                eTargets.push(sId);
                $(element).attr('vfqtid', eTargets.join(','));
                //Bind
                $(element).delayKeyup( onSubFieldChange, 1500 );
            });

            //Prepare query & check for empty subs
            //TODO: code duplicate
            /*var query = prepareQuery( sQuery, aSub );
            if( query === false ) {
                return;
            }*/

            //pauseElement(eTarget);

            //Do ajax query for first time
            /*doQuery( query, function( data ){
                if (data.error !== undefined ) {
                    return;
                }
                dataToElement( data, eTarget );
                unpauseElement(eTarget);
            });*/

            window.vfqStorage[$(eTarget).attr('id')] = Array();
            console.log('global array created');

            //Attach backup event
            $(eTarget).bind('change',function(){

                packElementValues( $(this) );

            });

        });

    };

    $('.ValuesFromQueryTarget').attachValuesFromQuery();

    var loading = 'data:image/gif;base64,'+
        'R0lGODlhQgBCAPMAAKampgAAADExMU9PT4+Pj2hoaKKiohISEn5+fgAAAAAAAAAAAAAAAAAAAAAA'+
        'AAAAACH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJ'+
        'CgAAACwAAAAAQgBCAAAE/xDISau9VBzMu/8VcRTWsVXFYYBsS4knZZYH4d6gYdpyLMErnBAwGFg0'+
        'pF5lcBBYCMEhR3dAoJqVWWZUMRB4Uk5KEAUAlRMqGOCFhjsGjbFnnWgliLukXX5b8jUUTEkSWBNM'+
        'c3tffVIEA4xyFAgCdRiTlWxfFl6MH0xkITthfF1fayxxTaeDo5oUbW44qaBpCJ0tBrmvprc5GgKn'+
        'fqWLb7O9xQQIscUamMJpxC4pBYxezxi6w8ESKU3O1y5eyts/Gqrg4cnKx3jmj+gebevsaQXN8HDJ'+
        'yy3J9OCc+AKycCVQWLZfAwqQK5hPXR17v5oMWMhQEYKLFwmaQTDgl5OKHP8cQjlGQCHIKftOqlzJ'+
        'sqVLPwJiNokZ86UkjDg5emxyIJHNnDhtCh1KtGjFkt9WAgxZoGNMny0RFMC4DyJNASZtips6VZkE'+
        'p1P9qZQ3VZFROGLPfiiZ1mDKHBApwisZFtWkmNSUIlXITifWtv+kTl0IcUBSlgYEk2tqa9PhZ2/F'+
        'yd3UcfIQAwXy+jHQ8R0+zHVHdQZ8A7RmIZwFeN7TWMpS1plJsxmNwnAYqc4Sx8Zhb/WPyqMynwL9'+
        'eMrpQwlfTOxQco1gx7IvOPLNmEJmSbbrZf3c0VmRNUVeJZe0Gx9H35x9h6+HXjj35dgJfYXK8RTd'+
        '6B7K1vZO/3qFi2MV0cccemkkhJ8w01lA4ARNHegHUgpCBYBUDgbkHzwRAAAh+QQJCgAAACwAAAAA'+
        'QgBCAAAE/xDISau9VAjMu/8VIRTWcVjFYYBsSxFmeVYm4d6gYa5U/O64oGQwsAwOpN5skipWiEKP'+
        'QXBAVJq0pYTqnCB8UU5KwJPAVEqK7mCbrLvhyxRZobYlYMD5CYxzvmwUR0lbGxNHcGtWfnoDZYd0'+
        'EyKLGAgClABHhi8DmCxjj3o1YYB3Em84UxqmACmEQYghJmipVGRqCKE3BgWPa7RBqreMGGfAQnPD'+
        'xGomymGqnsuAuh4FI7oG0csAuRYGBgTUrQca2ts5BAQIrC8aBwPs5xzg6eEf1lzi8qf06foVvMrt'+
        'm7fO3g11/+R9SziwoZ54DoPx0CBgQAGIEefRWyehwACKGv/gZeywcV3BFwg+hhzJIV3Bbx0IXGSJ'+
        'ARxDmjhz6tzJs4NKkBV7SkJAtOi6nyDh8FRnlChGoVCjSp0aRqY5ljZjplSpNKdRfxQ8Jp3ZE1xT'+
        'jpkqFuhGteQicFQ1xmWEEGfWXWKfymPK9kO2jxZvLstW1GBLwI54EiaqzxoRvSPVrYWYsq8byFWx'+
        'qcOs5vFApoKlEEm8L9va0DVHo06F4HQUA6pxrQZoGIBpyy1gEwlVuepagK1xg/BIWpLn1wV6ASfr'+
        'gpcuj5hkPpVOIbi32lV3V+8U9pVVNck5ByPiyeMjiy+Sh3C9L6VyN9qZJEruq7X45seNe0Jfnfkp'+
        '+u1F4xEjKx6tF006NPFS3BCv2AZgTwTwF1ZX4QnFSzQSSvLeXOrtEwEAIfkECQoAAAAsAAAAAEIA'+
        'QgAABP8QyEmrvVQIzLv/FSEU1nFYhWCAbEsRx1aZ5UG4OGgI9ny+plVuCBiQKoORr1I4DCyDJ7Gz'+
        'EyCYziVlcDhOELRpJ6WiGGJCSVhy7k3aXvGlGgfwbpM1ACabNMtyHGCAEk1xSRRNUmwmV4F7BXhb'+
        'Aot7ApIXCJdbMRYGA44uZGkSIptTMG5vJpUsVQOYAIZiihVtpzhVhAAGCKQ5vaQiQVOfGr+PZiYH'+
        'yLlJu8mMaI/GodESg7EfKQXIBtrXvp61F2Sg10RgrBwEz7DoLcONH5oa3fBUXKzNc2TW+Fic8OtA'+
        'QBzAfv8OKgwBbmEOBHiSRIHo0AWBFMuwPdNgpGFFAJr/li3D1KuAu48YRBIgMHAPRZSeDLSESbOm'+
        'zZs4oVDaKTFnqZVAgUbhSamVzYJIIb70ybSp06eBkOb81rJklCg5k7IkheBq0UhTgSpdKeFqAYNO'+
        'Za58+Q0qBpluAwWDSRWYyXcoe0Gc+abrRL7XviGAyNLDxSj3bArey+EuWJ+LG3ZF+8YjNW9Ac5m0'+
        'LEYv4A8GTCaGp5fykNBGPhNZrHpcajOFi8VmM9i0K9G/EJwVI9VM7dYaR7Pp2Fn3L8GcLxREZtJa'+
        'aMvLXwz2NFvOReG6Mel+sbvvUtKbmQgvECf0v4K2k+kWHnp8eeO+v0f79PhLdz91sts6C5yFfJD3'+
        'FVIHHnoWkPVRe7+Qt196eSkongXw4fQcCnW41F9F0+ETAQAh+QQJCgAAACwAAAAAQgBCAAAE/xDI'+
        'Sau9dAjMu/8VISCWcFiFYIBsS4lbJcSUSbg4aMxrfb68nFBSKFg0xhpNgjgMUM9hZye4URCC6MRU'+
        'GRxI18NSesEOehIqGjCjUK1pU5KMMSBlVd9LXCmI13QWMGspcwADWgApiTtfgRIEBYCHAoYEA2AY'+
        'WHCHThZ2nCyLgG9kIgehp4ksdlmAKZlCfoYAjSpCrWduCJMuBrxAf1K5vY9xwmTExp8mt4GtoctN'+
        'zi0FmJMG0csAwBUGs5pZmNtDWAeeGJdZBdrk6SZisZoaA5LuU17n9jpm7feK53Th+FXs3zd//xJO'+
        'yKbQGAIriOp1a9giErwYCCJGZEexQ8ZzIP8PGPplDRGtjj7OVUJI4CHKeQhfypxJs6bNDyU11rs5'+
        'IaTPnBpP0oTncwzPo0iTKjXWMmbDjPK8IShikmfIlVeslSwwseZHn1G0sitY0yLINGSVEnC6lFVX'+
        'igbi5iDJ8WW2tWkXTpWYd9tdvGkjFXlrdy1eDlOLsG34t9hUwgwTyvV2d6Big4efDe6LqylnDt+K'+
        'fO6cGddmNwRGf5qcxrNp0SHqDmnqzbBqblxJwR7WklTvuYQf7yJL8IXL2rfT5c7KCUEs2gt/G5wa'+
        'auoa57vk/Ur9L1LXb12x6/0OnVxoQC3lcQ1xXC93d2stOK8ur3x0u9YriB+ffBl4+Sc5158LMdvJ'+
        'F1Vpbe1HTgQAIfkECQoAAAAsAAAAAEIAQgAABP8QyEmrvXQMzLv/lTEUliBYxWCAbEsRwlaZpUC4'+
        'OCgKK0W/pl5uWCBVCgLE7ERBxFDGYUc0UDYFUclvMkhWnExpB6ERAgwx8/Zsuk3Qh6z4srNybb4w'+
        'AKYHIHlzHjAqFEh2ABqFWBRoXoESBAVmEkhZBANuGJeHXTKMmDkphC8amUN8pmxPOAaik4ZzSJ4S'+
        'cIA5VKO0BJOsCGaNtkOtZY9TAgfBUri8xarJYsOpzQAIyMxjVbwG0tN72gVxGGSl3VJOB+GaogXc'+
        '5ZoD6I7YGpLuU/DI9Trj7fbUyLlaGPDlD0OrfgUTnkGosAUCNymKEGzYIhI+JghE0dNH8QKZY+j/'+
        '8jEikJFeRwwgD4xAOJChwowuT8qcSbOmzQ5FRugscnNCypD5IkYc0VML0JB9iipdyrQptIc9yRyy'+
        'sC1jETkzU2IxZfVqgYk2yRxNdxUB2KWRUtK65nSX02Lb2NoTETOE1brNwFljse2q25MiQnLUZPWs'+
        'TBghp76QiLegXpXi2GlrnANqCHCz9g3uVu0AZYMZDU8zEFKuZtHdSKP7/Cb0r7/KDPwCaRr010kk'+
        'Wb8hkEq15xyRDA/czIr3JNWZdcCeYNbUQLlxX/CmCgquWTO5XxzKvnt5ueGprjc5tC0Vb+/TSJ4d'+
        'eNbsyPXG54rXHn4qyeMPa5+Sxp351JZU6SbMGXz+2YWeTOxZ4F4F9/UE4BeKRffWHgJ6EAEAIfkE'+
        'CQoAAAAsAAAAAEIAQgAABP8QyEmrvXQMzLv/lTEglmYhgwGuLEWYlbBVg0C0OCim9DwZMlVuCECQ'+
        'KoVRzCdBCAqWApTY2d0oqOkENkkeJ04m9fIqCCW7M0BGEQnUbu34YvD2rhIugMDGBucdLzxgSltM'+
        'WW0CAl9zBAhqEnYTBAV4ZAOWBU8WdZYrWZBWY3w2IYpyK3VSkCiMOU6uboM4dQNmbQSQtI+Jf0Sq'+
        't4Acsp45tcHCpr5zqsXJfLOfBbwhzsl7unWbFwhSlddUTqcclN664IE1iq5k3tTow5qn53Td3/Ac'+
        'CAdP9FXv+JwQWANIEFfBZAIjSRHY7yAGSuoESHDkbWFDhy8U7dsnxwBFbw7/O2iUgYxOrpDk7qFc'+
        'ybKly5cIK7qDSUHjgY37uumcNo3mBAE3gQaV6LOo0aNI4XkcGFJnFUc62bEUesCWJYpR/7nMeDPo'+
        'FCNGTiatBZSogYtHCTBN2sIjWnAi1po08vaavqpy0UBlyFJE15L1wNaF9yKo1ImCjTq5KWYS3xCD'+
        'h2gFUOcAqg8G6AK8G3lY2M4sgOzL+/QxQANBSQf+dxZ0m5KiD7jObBqx6gsDqlbgMzqHI7E/avu+'+
        '6Yp3Y8zAHVty20ETo7IWXtz2l1zt1Uz72ty8fM2jVrVq1GK5ieSmaxC/4TgKv/zmcqDHAXmHZH23'+
        'J6CoOONLPpG/eAoFZIdEHHz4LEWfJwSY55N30RVD3IL87VFMDdOh9B88EQAAIfkECQoAAAAsAAAA'+
        'AEIAQgAABP8QyEmrvbQUzLv/lVEg1jBYyGCAbEsRw1aZ5UC4OCiq80kZplVuCECQKprjhEZJyZpP'+
        'IkZUuL1iPeRAKSEIfFIOQiOUAAtlANMc/Jm4YQsVXuAtwQAYvtiOcwhkTVsZUU5uAlZ+BghpEkkv'+
        'aB2AiQB1UWZVOWORP3WNOAZflABAApc6m41jcDiGh3agqT8Eny4GtK+1LHO6fmxfvbsanL4hJrBh'+
        'i5nFFV7IIJOfBsF+uCEIphiAI6PMLikC2VObjN62A+E2H9sj1OYi6cQetxrd5hXYpu5y1vfj9v4C'+
        'XpgmkBkBK6sQ9CvYYke6LqtGGNknEEa4i+LMHBwxgqEHdOn/ynG4RTHgJI8oU6pcyXKlkZcwW5Y4'+
        'gPGiEY4JZc6gyVPAgT06gwodStQjSaFjAGokEDOoz3iUmMJUWNKfxZ7iXh6sarTOUzNcZS4sqmgs'+
        'QxFKRzI1WxDBgZ8Ub0llK7DUW3kD54YtBuOtAFYT9BLFdlfbVjl7W4jslHEX08Qf3AqAPItqwFA0'+
        '0+o4SLcYZkRSblmeMI2yiDSf98ode1hKgZ8hnmq+wLmRXMoE3o7CDPTD0WYHmxwAPAEblwE05ajz'+
        'dZsCcjzJJ7zGY+AtceaPK+im8Fb4ASQ0KXdoHvhtmu6kt5P22VvR6CXRJ6Cf4POS2wPip3yqr/17'+
        'hvjSnVKXGnry+VcefkjNV6AF1gmV2ykKOgIaWRT4FFAEACH5BAkKAAAALAAAAABCAEIAAAT/EMhJ'+
        'q720FMy7/5VREJZmIYUBriwlbpUZD2prf289FUM4pLeghIA4jWKwCWFQrCCaQo4BpRsWoBLZBDEg'+
        'UZa9aIdwreYoPxfPzMOKLdNjBrhLAgxpCpf+xpy3cll2S1giXX0SU1UST4UIXhhkVXtwgSxECIt/'+
        'Qng0IW03cZkVZJBBXG6dnqGNZgaLNgYEbD+wLKK2iIkDvLm3rbqVtYhxvm9gxhdEs3DJx7BTTJHA'+
        'wUJgeRdT1NUrZLyHHpiPztWGvKMgsk/kwVzDsczcHVOm8vY47PfdXo0E8fo2iBQQwGuIuCf/AHLw'+
        'RpAgtjvqGin0wItgmXkJJ1oopbGjx48g/0MCPNhPZIUBAlKqJLjskct6IlE2VBnGpM2bOHN6lJXP'+
        'HgqYLmQtA+pRJsFHX1r6ywgSzEoBMJbO6jmRiMwwr3SGo6p1Xtadlla88sdVDIKUq/BJLRsFj0o+'+
        'ftaaXKLSTVKyOc+mtONiaiWA6NRAjXXggF1detmSKnxAsQcDAg4IcHyHMeXHKhUTsKzGsQgzKok+'+
        '5ozmQM0gA0/fyXxjQOFFmw2LiV0P8gG+ILjAKnz67OEtArDIrCTaBoLCplyfTpnBtIvIv4kV5ouc'+
        'QuEvkmNIvoyhwGvsja0fcFF9AuTB8gwUduNd9fXSfI9PtvdQQmTq45urBqBlovoD9bxn3hd3NsVm'+
        'gYATRFZcVeiJV4IAC5rEnD0RAAAh+QQJCgAAACwAAAAAQgBCAAAE/xDISau9FCHMu/+VgRBWUVhE'+
        'YYBsS4lbhZyy6t6gaFNFPBmmFW4IIJAqhFEN2bNoiB6YcJL0SUy1IxUL7VSnAGmGJgHuyiZt9wJT'+
        'A2bg5k++Pa/ZGnBS/dxazW5QBgRgEnsvCIUhShMzVmWMLnuFYoJBISaPOV9IkUOOmJc4gyNgBqdd'+
        'g6YFA3Y3pIl3HWauo5OybCa1Q6SKuCm7s4mKqLgXhBY6moa3xkQpAwPLZVXIzi1A0QWByXvW1xwi'+
        '2rGbSb7gVNHkLqfn6GHf7/Lh7vM31kZGxfbYM9ED1EaM0MfPi4l/rf6cGsit4JV/PeqpcojhEMWL'+
        'GDNq3Agln0cjHP8nIBz50WPIhwIGpFRJ5qTLlzBjrkEgLaSGhoYKCDjA80DIaCl7qBnQs+cAnAWh'+
        'pVwZo6eAbTJ1qARYBCnMeDI7DqgHDohVNkQPtOSHICjXH2EPbL0IRIDbdRjK8hTw9V3blNMApM1L'+
        'kYDKpxiI1hIxDy6kVq948u1CIOVZEI0PCHjM6y/lcHMvV3bccSfdF8FYiDBlmVfmCoK76Bzrl/MN'+
        'op8pEOBZl0Pj2GgB31tbYSdVCWX5lh2aEgVUWQh4gkk9wS2P4j/eyjOwc+xONTszOH8++V0ByXrA'+
        'U+D5Yidp3dcMKK7w/beE7BRYynCruQWX+GIrSGYPncfYedQd4AYZeS+Ix9FsAliwX2+4adTYfwQ+'+
        'VxtG/V0TAQAh+QQJCgAAACwAAAAAQgBCAAAE/xDISau9FCHMu/+VgRCWZhGIAa4sJW6VGRdqa39v'+
        'PSFFWKS3oIRAqqCKO9gEpdwhhRgDSjccxZoAzRNAKPSgHRGBmqP8XDwybwsOHa9UmcRwpnSBbU55'+
        'aU3aC090gHlzYyd9c3hRillyEyJUK0SGLlNggpGCWCBSI5GWUF1bmpErUkRkBqUtUmpeq6ZHsIQA'+
        'gjRtp5S0Ll6MUJ2zuD/BF6ilqrvFxzybhZ7JQl29epO60DheXmwWudbX3Dy9xI+T48kEA8M3qua7'+
        'rd/wks3x0TUH9wKD9DYiXukSBe4JPCBg3j4+BdINSNekiwCBAg52SJgOUDAEAwxKBCWxo8ePIP9D'+
        'whtIUmQFigtTFnhIkqBJMyljfnlJs6bNm/Qwajz4hoNDiDRlMgpIMiPNLjEXwoCoD2e/lEO24VzS'+
        'buqHLlUJiVk34N5MiRjztaMjcEDWPHRS+irBUoBUnisXvu1KcOfGhQUxdL0Vwi6YtSL+tSDw0G8Q'+
        'wmYJESZ4loWBAQISg1ksoDEryJIPP6zMy/IjRo8jW6YcaS+YlV9rYW7clbMdgm9BEHYbAnJq2QPY'+
        'PBxgJy8HjE/icmvaBgFjCrYpCIg4Qfij5bFxPUz98Mny3sx3iIYX0PWQ4xMeulhOJvk1A9VPRq7g'+
        'Enk+I+S/ebFgWnl2CQjWz/CI/kCk9kvE9xIUAQCGd4AF0NGE3m3XnZSZVfpdEwEAIfkECQoAAAAs'+
        'AAAAAEIAQgAABP8QyEmrvZQQzLv/laFZCGIRiAGuLCVuFXqmbQ2KNFWGpWr/ANGJ4JvIMghYRgnE'+
        'vIoSQ7KyQzKD1Sbn6dJAj9Geq3TVhryxnCSLNSHV5gt3Iv0yUUwpXIsYlDV5RB0iX2xRgjUDBwJX'+
        'c0B6UFgFZR8GB5eRL1p4PAV7K5aXeQaRNaRQep8soQelcWOeri2ssnGptbMCB26vIbGJBwOlYL0h'+
        'pSKTGIqXBcVNKAXJGAiXi5TOWwjRqhUF1QK42EEE24gfBMu84hfkk+EX2u/OhOv1K8T2Zojf0vmz'+
        '0NEkFNBVLZg6f3K0RVt4Z+A3hB0WejLHbsBBiF3kYdzIsaPHjyz/CBZcBJKCxJMiCwooOSHagAIv'+
        'XzZjSbOmzZvitF3kyIkDuWUkS8JkCGVASgF+WEKL+dINwZcaMeoZegjnlqhWO5DDamuKqXQ8B1jU'+
        'aMDhgQJczUgRO9YDgqfXEJYV28+Ct0U7O/60iMHbJyn5KIbhm0tA3jjohL0yoAtcPQN008YQQFny'+
        'KraWgzRGxQ0UnLmKbRCg7JiC0ZlA+qCOgtmG0dJGKMcFgQ52FKo10JWiPCADYQzomMDs7Sszlcom'+
        'BawWm3w15KSPKa8GIJsCZRdIj4cWN9D2aNvX6RhFJfawFsaMtFcI39Lw5O3OAlYwepD9GuUkzGND'+
        'f8W+ZvgefWeBEn8AGDUbQuhcRGAfxtnD3DoRAAAh+QQJCgAAACwAAAAAQgBCAAAE/xDISau9lBDM'+
        'u/8VcRSWZhmEAa4shRxHuVVI2t6gAc+TSaE2nBAwGFgEoxBPApQNPbokpXAQKEMI1a/29FAPWokI'+
        'nFkCwwDgsnuCkSgwREY+QdF7NTTb8joskUY9SxpmBFl7EggDawCAGQd3FyhohoyTOANVen2MLXZ6'+
        'BghcNwZIZBSZgUOGoJV6KwSmaAYFr54Gs6KHQ6VVnYhMrmxRAraIoaLGpEiRwEx5N5m1J83OTK92'+
        'v1+Q1ry6vwAIpgLg3dS6yhPbA+nmdqJBHwaZ3OYchtA3BNP2GJf9AD0YCggMlwRTAwqUIygJXwE6'+
        'BUzBEDCgGsMtoh4+NFOAXpWLHP8y1oh3YZ9FkGlIolzJsqXLlzgkwpgIcwKCAjhzPhSApCcMVTBv'+
        'CtV4sqbRo0iTshFak1WHfQN6WgmaM5+EiFWqUFxIMJROnDN4UuSX1E5OMVyPGlSKaF+7bqHenogq'+
        'oKi9fQ/lponIk+zFUAkVthPHc9FLwGA58K17FO9DDBH9PguoMuXjFgSi2u2SWTKvwnpx0MIZ2h/o'+
        'gLQSlq5QauuW1axJpvac4/QUAW+GKGo2G3ZEwxl4ws5QZE3qzSU9R80NIHO5fUsUMX82/II4drcj'+
        'FXGR8EdxgPMYoyKHCmhmoM1V9/s9iyIait6x1+mIXEjrNeKmw59SMUSR6l5UE1EjM9txN1049RUU'+
        'lR771fFfUw1OEJUF38E0TzURJkLbUR31EwEAOwAAAAAAAAAAAA==';



})(jQuery);